import React, { useState } from 'react';
import { Modal } from 'antd';
import SideContext from '@/componets/gongzuotai/SideContext/SideContext';
import './Gongzuotai.css';
import SingleAdd from '@/componets/gongzuotai/AddContext/SingleAdd/SingleAdd';
import FastAdd from '@/componets/gongzuotai/AddContext/QuickAdd/FastAdd';
import EmailAdd from '@/componets/gongzuotai/AddContext/EmailAdd/EmailAdd';
import UrlAdd from '@/componets/gongzuotai/AddContext/UrlAdd/UrlAdd';


interface GongzuotaiProps {
  isVisible: boolean;
  onClose: () => void;
}

const Gongzuotai: React.FC<GongzuotaiProps> = ({ isVisible, onClose }) => {
  const [modalVisible, setModalVisible] = useState(isVisible);
  const [activeMenu, setActiveMenu] = useState('page1');

  const handleClose = () => {
    setModalVisible(false);
    onClose(); // Call onClose prop to notify parent component
  };

  const renderContent = () => {
    switch (activeMenu) {
      case 'page1':
        return <SingleAdd />;
      case 'page2':
        return <FastAdd />;
      case 'page3':
        return <EmailAdd />;
      default:
        return <UrlAdd />
    }
  };

  return (
    <>
      <Modal
        visible={modalVisible}
        onOk={handleClose}
        onCancel={handleClose}
        width={990}
        footer={null}
      >
        <div className="gongzuotai-container">
          <div className="gongzuotai-sidebar">
            <SideContext onMenuSelect={setActiveMenu} />
          </div>
          <div className="gongzuotai-content">
            {renderContent()}
          </div>
        </div>
      </Modal>
    </>
  );
};


export default Gongzuotai;
